package com.geektime.hello.controller;

import com.geektime.hello.service.TestService;
import com.geektime.hello.utils.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    private TestService testService;

    @Resource(name = "redisUtils")
    private RedisUtils redisUtils;

    @Value("${title}")
    private String title;

    @Value("${name}")
    private String name;

    @Cacheable(value = "default_cache")
    @GetMapping()
    public String getUser() {
        return title + testService.getUser();
    }

    @GetMapping(value = "/redis")
    public String redisUtils() {
        return  "【redisUtils】=" + redisUtils;
    }
}
